package com.orifine.orm.type;

import java.sql.Timestamp;
import java.text.SimpleDateFormat;

import com.orifine.orm.Information;
import com.orifine.orm.Type;
import com.orifine.orm.information.TimestampIncrementInfo;
import com.orifine.orm.model.ColumnModel;

public class TimestampType extends Type {
	private Timestamp value;
	private static final SimpleDateFormat format = new SimpleDateFormat("yyyy-M-dd HH:mm:ss");
	
	public TimestampType(){
		value = new Timestamp(System.currentTimeMillis());
	}
	
	public TimestampType(Timestamp timestamp){
		this.value = timestamp;
	}
	
	@Override
	public String getScriptType(ColumnModel column) {
		return "TIMESTAMP";
	}

	@Override
	public String getScriptValue(ColumnModel column) {
		return filterQuote(format.format(value));
	}

	@Override
	public Information getDefaultInfo(ColumnModel column) {
		return new TimestampIncrementInfo();
	}
}
